<div class="layuimini-main">

	<div class="layui-form layuimini-form" lay-filter="storage_form">
		<div class="layui-form-item">
			<label class="layui-form-label">IP</label>
			<div class="layui-input-block">
				<input type="text" name="ip" placeholder="输入IP地址" value="" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">CPU(核)</label>
			<div class="layui-input-block">
				<input type="number" name="cpu" placeholder="输入CPU核心数" value="" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">内存(G)</label>
			<div class="layui-input-block">
				<input type="number" name="memory" placeholder="输入内存大小" value="" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">GPU(个)</label>
			<div class="layui-input-block">
				<input type="number" name="gpu" placeholder="输入GPU数量" value="" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">地区</label>
			<div class="layui-input-block">
				<input type="text" name="area" placeholder="输入地区" value="" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">节点状态</label>
			<div class="layui-input-block">
				<input type="radio" name="node_status" value="运行中" title="运行中" checked="">
				<input type="radio" name="node_status" value="已停止" title="已停止">
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
			</div>
		</div>
	</div>
</div>
<script>
	layui.use(['form', 'table'], function() {
		var form = layui.form,
			layer = layui.layer,
			table = layui.table,
			$ = layui.$;

		/**
		 * 初始化表单，要加上，不然刷新部分组件可能会不加载
		 */
		form.render();

		// 当前弹出层，防止ID被覆盖
		var parentIndex = layer.index;

		//监听提交
		form.on('submit(saveBtn)', function(data) {
			var index = layer.alert('IP :' + data.field.ip + '</br>' + 'CPU(核) :' + data.field.cpu + '</br>' + '内存(G): ' +
				data.field.memory +
				'</br>' + 'GPU(个) :' + data.field.gpu + '</br>' + '地区: ' + data.field.area + '</br>' + '节点状态: ' + data.field.node_status, {
					title: '最终的提交信息'
				},
				function() {
					$.ajax({
						type: 'post',
						url: 'http://127.0.0.1:8199/gpuadd',
						data: data.field,
					})
					// 关闭弹出层
					layer.close(index);
					layer.close(parentIndex);

				});


			return false;
		});

	});
</script>
